package com.escafoide.smm;

import android.view.animation.Animation;
import android.view.animation.Transformation;
import android.widget.ImageView;

public class DropDownAnim extends Animation {
	private int initialHeight;
	private int targetHeight;
	private int max;
	ImageView view;

	public DropDownAnim(ImageView v, int initialHeight, int targetHeight, int max) {
		view = v;
		this.initialHeight = initialHeight;
		this.targetHeight = targetHeight/3;
		this.max = max;
	}

	protected void applyTransformation(float interpolatedTime, Transformation t) {
		int diff = targetHeight-initialHeight;
		if (initialHeight + diff > max) {
			int diff2 = max-initialHeight;
			view.getLayoutParams().height = (int) (initialHeight + diff2
					* interpolatedTime);
			view.requestLayout();
		} else {
			view.getLayoutParams().height = (int) (initialHeight + diff
					* interpolatedTime);
			view.requestLayout();
		}
	}

	public void initalize(int width, int height, int parentWidth,
			int parentHeight) {
		super.initialize(width, height, parentWidth, parentHeight);

	}

	public boolean willChangeBounds() {
		return true;
	}
}
